namespace DotNetNuke.Services.Localization
{
    using System;
    using System.Collections;

    /// -----------------------------------------------------------------------------
    /// <summary>
    /// The LocaleCollectionWrapper class provides a simple wrapper around a  
    /// <see cref="T:DotNetNuke.Services.Localization.LocaleCollection" />. 
    /// </summary>
    /// <remarks>
    /// The <see cref="T:DotNetNuke.Services.Localization.LocaleCollection" /> class
    /// implements a custom dictionary class which does not provide for simple databinding.
    /// This wrapper class exposes the individual objects of the underlying dictionary class
    /// thereby allowing for simple databinding to the colleciton of objects.
    /// </remarks>
    /// <history>
    /// [jbrinkman]	11/17/2004	Created
    /// </history>
    /// -----------------------------------------------------------------------------
    public class LocaleCollectionWrapper : IEnumerator, IEnumerable
    {
        private int _index = 0;
        private LocaleCollection _locales;

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="T:DotNetNuke.Services.Localization.LocaleCollectionWrapper" />
        /// class containing the specified collection <see cref="T:DotNetNuke.Services.Localization.Locale" /> objects.
        /// </summary>
        /// <param name="Locales">A <see cref="T:DotNetNuke.Services.Localization.LocaleCollection" /> object 
        /// which is wrapped by the collection. </param>
        /// <remarks>This overloaded constructor copies the <see cref="T:DotNetNuke.ModuleAction" />s
        /// from the indicated array.</remarks>
        /// <history>
        /// [jbrinkman]	11/17/2004	Created
        /// </history>
        /// -----------------------------------------------------------------------------
        public LocaleCollectionWrapper(LocaleCollection Locales)
        {
            this._locales = Locales;
        }

        public IEnumerator GetEnumerator()
        {
            return this;
        }

        public bool MoveNext()
        {
            this._index++;
            return (this._index < this._locales.Keys.Count);
        }

        public void Reset()
        {
            this._index = 0;
        }

        public object Current
        {
            get
            {
                return this._locales[this._locales.Keys[this._index]];
            }
        }
        //public
         object System.Collections.IEnumerator.Current
        {
            get
            {
                return this._locales[this._locales.Keys[this._index]];
            }
        }
    }
}

